package com.bsh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bsh.entity.Bo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserMapper extends BaseMapper<User> {

    /**
     * select * from  `my_user` where user_name =  'm0819MTU';
     * -- 两个等于条件查询
     * select * from  `my_user` where user_name =  'm0819MTU' and sex = 0;
     * select * from  `my_user` where sex = 0  and user_name =  'm0819MTU';
     * select * from  `my_user` where user_name =  'm0819MTU' or sex = 0;
     * select * from  `my_user` where sex = 0  or user_name =  'm0819MTU';
     *
     * -- 三个等于条件查询
     * select * from  `my_user` where user_name =  'm0819MTU' and sex = 0 and phone = '15610056939';
     * select * from  `my_user` where user_name =  'm0819MTU' and sex = 0 or phone = '15610056939';
     * select * from  `my_user` where user_name =  'm0819MTU' or  sex = 0 and phone = '15610056939';
     * select * from  `my_user` where user_name = 'm0819MTU' or sex = 0 or  phone = '15610056939';
     *
     *
     *
     * -- Like 条件查询
     * SELECT * FROM my_user WHERE user_name LIKE '%0819%'
     * SELECT * FROM my_user WHERE user_name LIKE '%0819%' and sex = 0
     * SELECT * FROM my_user WHERE user_name LIKE '%0819%' or sex = 0
     *
     * SELECT * FROM my_user WHERE sex = 0  and user_name LIKE '%0819%'
     * SELECT * FROM my_user WHERE sex = 0  or user_name LIKE '%0819%'
     *
     *
     *
     * -- right Like 条件查询
     * SELECT * FROM my_user WHERE user_name LIKE 'MTU%'
     * SELECT * FROM my_user WHERE user_name LIKE 'MTU%' and sex = 0
     * SELECT * FROM my_user WHERE user_name LIKE 'MTU%' or sex = 0
     *
     * SELECT * FROM my_user WHERE sex=0 AND user_name LIKE  'MTU%'
     * SELECT * FROM my_user WHERE sex=0 or user_name LIKE  'MTU%'
     *
     *
     * -- Left Like 条件查询
     * SELECT * FROM my_user WHERE user_name LIKE  '%m089'
     * SELECT * FROM my_user WHERE user_name LIKE  '%m089' and sex = 0
     * SELECT * FROM my_user WHERE user_name LIKE  '%m089' or  sex = 0
     *
     * SELECT * FROM my_user WHERE sex = 0 AND user_name LIKE '%m089'
     * SELECT * FROM my_user WHERE sex = 0 or  user_name LIKE '%m089'
     *
     *
     * -- 分组查询
     * SELECT  COUNT(*) from my_user GROUP BY sex
     * SELECT  MAX(balance) FROM my_user GROUP BY sex
     * SELECT  MIN(balance) FROM my_user GROUP BY sex
     * SELECT  SUM(balance) FROM my_user GROUP BY sex
     * SELECT  AVG(balance) FROM my_user GROUP BY sex
     *
     *
     * -- 排序查询
     * SELECT * FROM my_user order by create_date
     * SELECT * FROM emp order by create_date desc
     *
     *
     * -- 分页查询
     * SELECT * FROM my_user LIMIT 0,100
     * SELECT * FROM my_user LIMIT 0,1000
     *
     * -- 添加函数查询
     *
     * select length(user_name) from my_user -- 数据的长度
     * SELECT user_name ,SUBSTR(user_name,1,3) as new_name FROM my_user;-- 截取[1,3]
     * SELECT user_name,LOWER(user_name) new_name from my_user ; -- 数据转小写
     * SELECT user_name,LOWER(user_name) from my_user ; -- 数据转小写
     * select user_name,concat(user_name,'123') from my_user -- 拼接数据
     * select user_name,replace(user_name,'a','666') new_name from my_user -- 把a字符替换成666
     */

    @Update("ALTER TABLE  my_user  ADD INDEX  #{indexName} (#{columnName})")
    void addIndex(@Param("tableName") String tableName,@Param("indexName") String indexName,@Param("columnName") String columnName);
}
